﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CameraCtrl : MonoBehaviour
{
    
    public enum  ECameraCtrlType
    {
        None,
        FollowRole,
        Story,
    }

    private ECameraCtrlType m_eCameraCtrlType = ECameraCtrlType.None;

    private GameObject m_followRole = null;
    private Vector3 m_roleOffset;
    
    void Start()
    {
        
    }

    public void FollowRole(GameObject obj, Vector3 offset)
    {
        m_followRole = obj;
        m_eCameraCtrlType = ECameraCtrlType.FollowRole;
        m_roleOffset = offset;
        transform.position = obj.transform.position + m_roleOffset;
        transform.LookAt(obj.transform.position);
    }

    // Update is called once per frame
    void Update()
    {
        if (m_eCameraCtrlType == ECameraCtrlType.FollowRole)
        {
            transform.position = m_followRole.transform.position + m_roleOffset;
        }
    }
}
